import { Application } from "egg";
import { WeaverAuth, WeaverEcologyHRMService, WeaverWorkflow } from "../lib/weaver";
import { Weaver } from "../lib/weaver/type";

export default class CodoWeaver {
	constructor(private app: Application) {}

	WeaverAuth = WeaverAuth;
	WeaverWorkflow = WeaverWorkflow;

	hrm = {
		WeaverEcologyHRMService,
	};

	getWeaverAuthInstance(config: Weaver.Config) {
		return new WeaverAuth(this.app, config);
	}
	getWeaverWorkflowInstance(config: Weaver.Config, token: string) {
		return new WeaverWorkflow(this.app, config, token);
	}
	/** 获取HRM的相关管理接口，与workflow等是不同的服务，只需baseUrl，weaver配置好ip白名单即可访问 */
	getHrmInstance(baseUrl: string) {
		return new WeaverEcologyHRMService(baseUrl, this.app);
	}
}
